import wepy from 'wepy'
export default class extends wepy.mixin {
  data = {
    catesList: [],
    active: 0,
    wh: 0,
    sonCateList: []
  }
  methods = {
    onChange(e) {
      console.log(e.detail)
      this.sonCateList = this.catesList[e.detail].children
    },
    goGoodsList(id) {
      wepy.navigateTo({
        url: `/pages/goods_list?cid=${id}`
      })
    }
  }
  onLoad() {
    this.getCatesList()
    this.getHeight()
  }
  async getCatesList() {
    const { data: res } = await wepy.getData('/categories')
    if (res.meta.status !== 200) {
      return wepy.baseToast()
    }
    this.catesList = res.message
    this.sonCateList = res.message[0].children
    this.$apply()
  }
  async getHeight() {
    const res = await wepy.getSystemInfo()
    this.wh = res.windowHeight
    console.log(res)
  }
}
